import sys
import os

# 尝试多种可能的插件路径
try:
    import PyQt5
    paths_to_try = [
        os.path.join(os.path.dirname(PyQt5.__file__), 'Qt', 'plugins', 'platforms'),
        os.path.join(os.path.dirname(PyQt5.__file__), 'Qt5', 'plugins', 'platforms'),
        os.path.join(os.path.dirname(PyQt5.__file__), 'plugins', 'platforms'),
        os.path.join(sys.prefix, 'Lib', 'site-packages', 'PyQt5', 'Qt', 'plugins', 'platforms'),
        os.path.join(sys.prefix, 'Lib', 'site-packages', 'PyQt5', 'Qt5', 'plugins', 'platforms')
    ]
    
    for path in paths_to_try:
        if os.path.exists(path):
            os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = path
            print(f"找到并设置插件路径: {path}")
            break
    else:
        print("警告: 未找到有效的 Qt 平台插件路径")
except Exception as e:
    print(f"设置环境变量时出错: {e}")

import rasterio.sample  # 强制显式导入
from PyQt5.QtWidgets import QApplication
from main_window import MainWindow
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D

def main():
    """
    程序入口函数
    第四次全国文物普查内业工具包 Ver.0.94
    """
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()
